package com.zdft.promotion.common.util;

import org.apache.commons.codec.binary.Hex;

import java.security.MessageDigest;

/**
 * 编码工具类
 */
public class EncoderUtil {
    /**
     * MD5加密
     *
     * @param arg 入参
     * @return 出参
     */
    public static String encodeMD5(String arg) {
        try {
            MessageDigest digest = MessageDigest.getInstance("MD5");
            byte[] codes = digest.digest(arg.getBytes("UTF-8"));
            return Hex.encodeHexString(codes);
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
